#include <math.h>
#include<iostream>
#include <stdio.h>
using namespace std;
int a[13], full, n, res = 0;
 
void DFS(int k, int column, int lcorner, int rcorner)
{
	if (k == n)
	{
		if (++res <= 3)
		{
			printf("%d", a[0]+1);
			for (int j = 1; j < n; ++j)
				printf(" %d", a[j]+1);
			putchar('\n');
		}
		return;
	}
	for (int p = full & ~(column | lcorner | rcorner); p; )
	{
		int i = p & -p;
		p -= i;
		if (res < 3) a[k] = log(double(i+0.5))/log(2.);
		DFS(k+1, column+i, (lcorner+i)/2, (rcorner+i)*2);
	}
}
 
int main()
{
	//freopen("checker.in", "r", stdin);
	//freopen("checker.out", "w", stdout);
	scanf("%d", &n);
	full = (1 << n ) - 1;
	if (n == 6)
		DFS(0, 0, 0, 0);
	else if (n & 1)
	{
		for (int i = 0; i < n/2; ++i)
			a[0] = i, DFS(1, 1 << i, i ? 1 << i-1 : 0, 1 << i+1);
		int t = res;
		a[0] = n/2; DFS(1, 1 << n/2, 1 << n/2-1, 1 << n/2+1);
		res += t;
	}
	else
	{
		for (int i = 0; i < n/2; ++i)
			a[0] = i, DFS(1, 1 << i, i ? 1 << i-1 : 0, 1 << i+1);
		res *= 2;
	}
	printf("%d\n", res);
	system("pause");
	return 0;
}
